package com.xdhl.fu.order.controller;

import com.xdhl.fu.common.core.web.controller.BaseController;
import com.xdhl.fu.common.core.web.domain.AjaxResult;
import com.xdhl.fu.common.core.web.page.TableDataInfo;
import com.xdhl.fu.flight.info.api.mongodb.domain.MGReservation;
import com.xdhl.fu.order.domain.OrderInfo;
import com.xdhl.fu.order.service.IOrderInfoService;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 会员订单信息控制层
 *
 * @author 朱力维
 * @time 2022/6/11 19:55
 */
@RestController
public class MemberOrderController extends BaseController {

    @Resource
    private IOrderInfoService orderInfoService;

    /**
     * 获取会员订单列表
     */
    @GetMapping("/list")
    public TableDataInfo list() {
        Page<MGReservation> list = orderInfoService.listMemberOrder();
        return getDataTable(list.toList(), list.getTotalElements());
    }

    /**
     * 获取会员订单详情
     */
    @GetMapping("/details/{orderDataId}")
    public AjaxResult orderDetails(@PathVariable String orderDataId) {
        return AjaxResult.success(orderInfoService.getById(orderDataId));
    }

    /**
     * 获取会员改期中的订单列表
     */
    @GetMapping("/changeList")
    public TableDataInfo refundAndChangeList() {
        startPage();
        List<OrderInfo> list = orderInfoService.listMemberChangeOrder();
        return getDataTable(list);
    }

    /**
     * 获取会员订单待支付列表
     */
    @GetMapping("/unpaid")
    public TableDataInfo unpaidList() {
        startPage();
        List<OrderInfo> list = orderInfoService.listUnpaid();
        return getDataTable(list);
    }


}
